import { defineStore } from 'pinia'

// 定义 State 类型
interface CounterState {
  count: number
}

export const useCounterStore = defineStore('counter', {
  state: (): CounterState => ({ count: 10 }),
  getters: {
    double: (state: CounterState) => state.count * 2, // 显式指定 state 的类型
  },
  actions: {
    increment() {
      this.count++  // `this` 会自动推导为 CounterState 类型
    },
  },
})
